<?php
#[引入无限级分类]
$r_url = "admin.php?file=dealer";
#[信息录入]
if($sysAct == "add")
{
	#[判断权限]
	if($_SESSION["admin"]["typer"] != "system" && !$QG_AP["msg_".$sysgroupid])
	{
		Error("对不起，您没有权限操作当前功能","admin.php?file=index");
	}
	Foot("dealer.add.qg");
}
elseif($sysAct == "addok")
{
    if(!isset($rgid)){
        Error("操作不正确，无法取得ID号信息...","admin.php?file=dealer_rg&act=list");
    }
	$name = $STR->safe($name);
	if(!$name)
	{
		Error("名称不允许为空...","admin.php?file=dealer&act=add&rgid=".$rgid."&rgname=".$rgname);
	}

    $sql = "INSERT INTO ".$prefix."dealer(name,content,regionId) VALUES('".$name."','".$content."','".$rgid."')";

	$insert_id = $DB->qgInsert($sql);

	unset($name);
	unset($sql);
	
	Error("信息添加成功...","admin.php?file=dealer_rg&act=list");
}
elseif($sysAct == "modify")
{
	$id = intval($id);
	if(!$id || $id == 0)
	{
		Error("操作不正确，无法取得ID号信息...","admin.php?file=dealer_rg&act=list");
	}
	$rs = $DB->qgGetOne("SELECT * FROM ".$prefix."dealer WHERE id='".$id."'");
	
	//$content = FckToHtml($rsC["content"]);
	//$fckeditor = FckEditor("content",$content,"LongDefault","400px","100%");
	Foot("dealer.modify.qg");
}
elseif($sysAct == "modifyok")
{
	$id = intval($id);
	if(!$id || $id == 0)
	{
		Error("操作不正确，无法取得ID号信息...","admin.php?file=dealer_rg&act=list");
	}
	
	$name = $STR->safe($name);
	if(!$name)
	{
		Error("名称不允许为空...","admin.php?file=dealer&act=add");
	}

	$sql = "UPDATE ".$prefix."dealer SET name='".$name."',content='".$content."' WHERE id='".$id."'";
	$DB->qgQuery($sql);#[写入数据库]
	unset($sql);
    
	Error("信息编辑成功...","admin.php?file=dealer_rg&act=list");
}
elseif($sysAct == "delete")
{
$id = intval($id);
	if(!$id || $id == 0)
	{
		Error("操作不正确，无法取得ID号信息...","admin.php?file=dealer_rg&act=list");
	}

	$DB->qgQuery("DELETE FROM ".$prefix."dealer WHERE id='".$id."'");
	
	Error("删除完成！","admin.php?file=dealer_rg&act=list");
}
else
{
}

function get_son_id_array($id,$array,$myid=array())
{
	foreach($array AS $key=>$value)
	{
		if($value["parentid"] == $id)
		{
			$myid[$value["id"]] = $value["id"];
			get_son_id_array($value["id"],$array,$myid);
		}
	}
	return $myid;
}

?>